package cn.ekgc.common.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.time.Duration;

/**  自定义监听器
 *
 */

@Slf4j
public class MyListener implements SpringApplicationRunListener {

    public void starting(ConfigurableBootstrapContext bootstrapContext) {
        System.out.println("starting...");
        log.info("starting...");
    }

    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext,
                                     ConfigurableEnvironment environment) {
        System.out.println("environmentPrepared...");
        // secret 服务器中  不让别人知道的
    }

    public void contextPrepared(ConfigurableApplicationContext context) {

        System.out.println("contextPrepared...");

    }


    public void contextLoaded(ConfigurableApplicationContext context) {


    }

    public void started(ConfigurableApplicationContext context, Duration timeTaken) {

    }

    public void ready(ConfigurableApplicationContext context, Duration timeTaken) {

    }

    public void failed(ConfigurableApplicationContext context, Throwable exception) {

    }
}
